package com.bcu.calculus.controller;

import com.bcu.calculus.entity.*;
import com.bcu.calculus.service.CheckAttendanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.text.ParseException;
import java.util.List;

@Api(tags = "18 考勤管理模块")
@RestController
@RequestMapping("/api/Attendance")
public class CheckAttendanceController {

    @Resource
    private CheckAttendanceService checkAttendanceService;

    @ApiOperation(value = "增加")
    @PostMapping(value = "/insertSelective")
    public Message<?> insertSelective(CheckAttendanceNumber checkAttendanceNumber) throws ParseException {
        return checkAttendanceService.insertSelective(checkAttendanceNumber);
    }


    @ApiOperation(value = "删除")
    @PostMapping(value = "/deleteByPrimaryKey")
    public Message<?> deleteByPrimaryKey(String checkId) {
        return checkAttendanceService.deleteByPrimaryKey(checkId);
    }


    @ApiOperation(value = "修改")
    @PutMapping(value = "/updateByPrimaryKeySelective")
    public Message updateByPrimaryKeySelective(CheckAttendanceNumber checkAttendanceNumber) throws ParseException {
        return checkAttendanceService.updateByPrimaryKeySelective(checkAttendanceNumber);
    }


    @ApiOperation(value = "查所有")
    @GetMapping(value = "/selectAll")
    public Message<List<CheckAttendance>> selectAll(){
        return checkAttendanceService.selectAll();
    }


    @ApiOperation(value = "关键字查询")
    @GetMapping(value = "/selectById")
    public Message<List<CheckAttendance>> selectById(String checkId){
        return checkAttendanceService.selectById(checkId);
    }

    @ApiOperation(value = "根据学期id，所属标题，所属标题编号查询")
    @GetMapping(value = "/selectByCheckSemIdAndCheckListAndCheckListId")
    public Message<List<CheckAttendance>> selectByCheckSemIdAndCheckListAndCheckListId(@RequestParam(name = "CheckSemId") String checkSemId,@RequestParam(name = "checkList") String checkList,@RequestParam(name = "checkListId") String checkListId){
        return checkAttendanceService.selectByCheckSemIdAndCheckListAndCheckListId(checkSemId,checkList,checkListId);
    }

}
